<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>for循环中的var与let</title>
		<script>
			window.onload=function(){
				var myVar=document.getElementById('varCount')
				var myLet=document.getElementById('letCount')
				// 输出十个 10
				for (var i = 0; i < 10; i++) {
				  setTimeout(function(){
					myVar.innerHTML+=i+'&nbsp;';
				  })
				}
				// 输出 0123456789
				for (let j = 0; j < 10; j++) {
				  setTimeout(function(){
				    myLet.innerHTML+=j+'&nbsp;';
				  })
				}
			}
			
		</script>
	</head>
	<body>
		<div id="varCount">var变量循环：</div>
		<div id="letCount">let计数循环：</div>
	</body>
</html>
